Skip to content

优化投影管理文件夹已存在提示 - #6664

Merged
Glavo merged 7 commits into
HMCL-dev:mainfrom
CiiLu:tare/agent-solo-wood
Aug 13, 2026
Merged

优化投影管理文件夹已存在提示#6664
Glavo merged 7 commits into
HMCL-dev:mainfrom
CiiLu:tare/agent-solo-wood

Conversation

@CiiLu

@CiiLu CiiLu commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions github-actions Bot added the 10+ label Aug 12, 2026
@Glavo

Glavo commented Aug 12, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce789a1ad8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

handler.reject(i18n("schematics.create_directory.failed", targetDir));
}
}, "", new RequiredValidator(), new Validator(i18n("schematics.create_directory.failed.invalid_name"), FileUtils::isNameValid));
}, "", new RequiredValidator(), new Validator(i18n("schematics.create_directory.failed.invalid_name"), FileUtils::isNameValid), new Validator(i18n("schematics.create_directory.failed.already_exists"), (it) -> !finalExistingFolders.contains(it)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recheck directory existence when submitting the name

The validator only checks a case-sensitive snapshot captured before the prompt opens. If another process creates the directory while the dialog is open, or on a case-insensitive filesystem the user enters different casing for an existing name, validation succeeds and Files.createDirectories(targetDir) silently accepts the already-existing directory; the dialog then resolves as though a new folder was created. Retain a live Files.exists(targetDir) check in the submission callback in addition to the interactive validator.

Useful? React with 👍 / 👎.

i18n("schematics.create_directory.prompt"),
(result, handler) -> {
Path targetDir = parent.resolve(result);
if (Files.exists(targetDir)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么要删除这一处检查?

@ToobLac

ToobLac commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

这么干的意义是什么呢(

原来的检查应该能胜任判断是否存在的功能吧?

@Glavo

Glavo commented Aug 13, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d2a070ea8e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +168 to +171
try (var list = Files.list(parent)) {
existingFolders = list.map(Path::getFileName)
.map(Path::toString)
.collect(Collectors.toSet());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Catch failures raised while consuming the directory stream

If directory enumeration fails after Files.list(parent) has returned—for example on a disconnected network share or removed device—the stream pipeline wraps that late I/O failure in UncheckedIOException, so this catch (IOException) is bypassed and the JavaFX action exits before opening the prompt. Catch UncheckedIOException as well so the intended empty-set fallback applies to traversal failures, not only failures while opening the stream.

Useful? React with 👍 / 👎.

@Glavo

Glavo commented Aug 13, 2026

Copy link
Copy Markdown
Member

我改改吧。

@github-actions github-actions Bot added 100+ and removed 10+ labels Aug 13, 2026
@Glavo
Glavo requested a balanced review from Copilot August 13, 2026 13:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds proactive duplicate-folder validation to schematic directory creation.

Changes:

  • Introduces a case-aware filename set utility.
  • Validates directory names before submission.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
FileNameSet.java Adds filename collection and lookup support.
SchematicsPage.java Adds duplicate-name validation to folder creation.
Suppressed comments (1)

HMCLCore/src/main/java/org/jackhuang/hmcl/util/FileNameSet.java:42

  • A null predicate currently rejects every directory entry. The new caller passes null, so existingPaths is always empty and the added validator never shows the already-exists message while typing. Treat null as “no filter.”
                if (predicate != null && predicate.test(path)) {

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/util/FileNameSet.java Outdated
@Glavo

Glavo commented Aug 13, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ae1e96aa2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +42 to +43
if (predicate != null && predicate.test(path)) {
set.add(path.getFileName().toString());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include every entry when the predicate is absent

When FileNameSet.list(parent, null) is called from SchematicsPage, this condition is false for every path, so the returned set is always empty and the new interactive already-exists validator never reports any existing name. Treat a null predicate as accepting all entries, while retaining the predicate check when one is supplied.

Useful? React with 👍 / 👎.

Comment on lines +37 to +38
boolean caseSensitive = OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS
&& directory.getFileSystem() == FileSystems.getDefault();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Correct the case-sensitivity selection

The flag is inverted relative to the filesystem behavior: a Windows default filesystem is treated as case-sensitive, while a typical Linux default filesystem is treated as case-insensitive. Once entries are populated, this allows differently cased duplicates through validation on Windows and incorrectly blocks distinct names such as Foo and foo on Linux.

Useful? React with 👍 / 👎.

@Glavo
Glavo merged commit 770c58c into HMCL-dev:main Aug 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants